web/src/pages/[...listing].astro
489 lines · 12684 bytes
1---
2
3import Layout from '@layouts/Layout.astro';
4import ServiceList from '@components/things/ServiceList.astro';
5import Comments from '@components/things/Comments.svelte';
6import GitHubDetailedInfo from '@components/things/GitHubDetailedInfo.astro';
7import PrivacyPolicyDetails from '@components/things/PrivacyPolicyDetails.astro';
8import WebsiteDetailedInfo from '@components/things/WebsiteDetailedInfo.astro';
9import type { AwesomePrivacy, Section, Service } from '../types/Service';
10import { fetchData, slugify } from '@utils/fetch-data';
11import { fetchGitHubStats } from '@utils/fetch-repo-info';
12import { fetchTosdrPrivacy } from '@utils/fetch-privacy-policy';
13import { fetchWebsiteInfo } from '@utils/fetch-website-info';
14import { parseMarkdown, formatLink } from '@utils/parse-markdown';
15import FontAwesome from '@components/form/FontAwesome.svelte';
16import Button from '@components/form/Button.astro';
17
18interface Props extends Service {
19 slug: string;
20 parentSection: Section;
21 categoryName: string;
22}
23
24const {
25 name,
26 description,
27 url,
28 github,
29 tosdrId,
30 icon,
31 followWith,
32 securityAudited,
33 openSource,
34 acceptsCrypto,
35 parentSection,
36 categoryName,
37} = Astro.props;
38
39
40/**
41 * Make a list of keywords, for the <meta keywords> tag
42 */
43const makeKeyWordTag = () => {
44 const keywords: string[] = [];
45 keywords.push(`free and open source ${parentSection.name} software`);
46 keywords.push(`private ${parentSection.name} comparison`);
47 (parentSection.alternativeTo || []).forEach((alt: string) => {
48 keywords.push(`privacy-respecting ${alt} alternative`);
49 keywords.push(`free open source ${alt} alternative`);
50 });
51 (parentSection.services || []).forEach((serv: Service) => {
52 keywords.push(serv.name);
53 });
54 keywords.push('ad free');
55 keywords.push('open source software');
56 keywords.push('privacy respecting apps');
57 return keywords.join(', ');
58};
59
60/**
61 * Make a page title
62 */
63const makePageTitle = () => {
64 return `${name} | ${parentSection.name} | ${categoryName} | Awesome Privacy`;
65};
66
67/**
68 * Make a string page intro, for the description tag
69 */
70const makeDescriptionTag = () => {
71 return `Compare ${name} and other ${parentSection.name} at Awesome Privacy\n`
72 + description
73 + '\nAll this, and much more at Awesome Privacy, '
74 + 'the free and open source list of private software alternatives.';
75};
76
77// Return a list of Services, except for the currtent one
78const filterServices = () => {
79 return parentSection.services.filter((service: Service) => service.name !== name);
80};
81
82export async function getStaticPaths() {
83 const pages = await fetchData().then((data) => {
84 const results: Array<Props> = [];
85 if (!data || !data.categories) return results;
86 (data as AwesomePrivacy).categories.forEach((category) => {
87 category.sections.forEach((section) => {
88 const services = (section.services || []).map((service) => {
89 return {
90 slug: `${slugify(category.name)}/${slugify(section.name)}/${slugify(service.name)}`,
91 parentSection: section,
92 categoryName: category.name,
93 ...service,
94 };
95 });
96 results.push(...services);
97 });
98
99 });
100 return results;
101 });
102
103 return pages.map((props: Props) => {
104 return {params: { listing: props.slug }, props };
105 });
106}
107
108const makePaginationLinks = () => {
109 const allServices = parentSection.services || [];
110 const index = allServices.findIndex(item => item.name === name);
111 const previousItem = index > 0 ? allServices[index - 1].name : null;
112 const nextItem = index < allServices.length - 1 ? allServices[index + 1].name : null;
113 return { previous: previousItem, next: nextItem };
114};
115
116const { previous, next } = makePaginationLinks();
117
118
119const ignoredSites = ['github.gom', 'wikipedia.'];
120
121// Fetch detailed data about the services GitHub repo, privacy policy and website
122const githubData = github ? await fetchGitHubStats(github) : null;
123const privacyData = tosdrId ? await fetchTosdrPrivacy(tosdrId) : null;
124const websiteData = (url && !ignoredSites.some(ignoredSite => url.includes(ignoredSite))) ? await fetchWebsiteInfo(url) : null;
125
126---
127
128<Layout title={makePageTitle()} keywords={makeKeyWordTag()} description={makeDescriptionTag()} >
129 <main>
130 <section>
131 <div class="service-head">
132 <h2>{name}</h2>
133 <span class="url-wrap">
134 <a class="service-url" href={url}>{formatLink(url)}</a>
135 <span class="follow-with">{followWith}</span>
136 </span>
137 </div>
138 <div class="breadcrumbs">
139 <span>
140 <a href="/">Awesome Privacy</a>
141 ➔ <a href={`/${slugify(categoryName)}`}>{categoryName}</a>
142 ➔ <a href={`/${slugify(categoryName)}/${slugify(parentSection.name)}`}>{parentSection.name}</a>
143 ➔ <a href={`/${slugify(categoryName)}/${slugify(parentSection.name)}/${slugify(name)}`}>{name}</a>
144 </span>
145 </div>
146 <div class="intro">
147 <img
148 width="60"
149 height="60"
150 loading="lazy"
151 decoding="async"
152 class="service-icon"
153 alt={`${name} Icon`}
154 data-service-url={formatLink(url)}
155 src={icon || `https://icon.horse/icon/${formatLink(url)}`}
156 />
157 <div>
158 <p class="description" set:html={parseMarkdown(description)}></p>
159 <ul>
160 { url && (
161 <li>
162 <b>Homepage:</b>
163 <a href={url}>{formatLink(url)}</a>
164 </li>
165 )}
166 { github && (
167 <li>
168 <b>GitHub:</b>
169 <a href={`https://github.com/${github}`}>github.com/{github}</a>
170 </li>
171 )}
172 { tosdrId && (
173 <li>
174 <b>ToS;DR:</b>
175 <a href={`https://tosdr.org/en/service/${tosdrId}`}>{`tosdr.org/en/service/${tosdrId}`}</a>
176 </li>
177 )}
178 { url && (
179 <li>
180 <b>Web info:</b>
181 <a href={`https://web-check.xyz/results/${formatLink(url)}`}>{`web-check.xyz/results/${formatLink(url)}`}</a>
182 </li>
183 )}
184 </ul>
185 </div>
186 </div>
187 <div class="highlights">
188 { securityAudited && (
189 <span class="meta-item great" title={`${name} has been security audited by an accredited auditor, with results published publicly`}>
190 <FontAwesome iconName="securityAudited" /> Security Audited
191 </span>
192 )}
193 { acceptsCrypto && (
194 <span class="meta-item great" title={`${name} accepts anonymous payment methods`}>
195 <FontAwesome iconName="cryptoAccepted" /> Crypto Payments Accepted
196 </span>
197 )}
198 { securityAudited === false && (
199 <span class="meta-item warning" title={`${name} has not been audited`}>
200 <FontAwesome iconName="notSecurityAudited" /> No Security Audit
201 </span>
202 )}
203 { (openSource === false) && (
204 <span class="warning">
205 <FontAwesome iconName="closedSource" />
206 Not Open Source
207 </span>
208 )}
209 { openSource || (github && openSource !== false) ? (
210 <span class="meta-item great" title={`${name} is open source`}>
211 <FontAwesome iconName="openSource" /> Open Source
212 </span>
213 ) : null }
214 </div>
215 </section>
216 { privacyData && (
217 <section>
218 <h3>{name} Privacy Policy</h3>
219 <PrivacyPolicyDetails privacyData={privacyData} />
220 </section>
221 )}
222 { github && githubData && (
223 <section class="github-wrap">
224 <h3>{name} Source Code</h3>
225 <GitHubDetailedInfo gitHubData={githubData} repo={github} />
226 </section>
227 )}
228
229 { websiteData && (
230 <section>
231 <h3>{name} Website</h3>
232 <WebsiteDetailedInfo url={url} websiteInfo={websiteData} />
233 </section>
234 )}
235 <section>
236 <h3>{name} Reviews</h3>
237 <Comments client:visible />
238 </section>
239 <section>
240 <h3>More {parentSection.name}</h3>
241 <ServiceList
242 services={filterServices()}
243 subHeading={true}
244 noGitHubMetrics={true}
245 buttonLink={`/${slugify(categoryName)}/${slugify(parentSection.name)}`}
246 categoryName={categoryName}
247 sectionName={parentSection.name}
248 />
249 </section>
250
251 <div class="pagination-navigation">
252 { previous ? (
253 <Button url={`/${slugify(categoryName)}/${slugify(parentSection.name)}/${slugify(previous)}`}>
254 <span>← Previous</span>
255 <p>{previous}</p>
256 </Button>
257 ) : <p class="nothing"></p>}
258 <a href={`/${slugify(categoryName)}/${slugify(parentSection.name)}`} class="go-to-category">
259 View {parentSection.name} ({(parentSection.services || []).length})
260 </a>
261 { next && (
262 <Button url={`/${slugify(categoryName)}/${slugify(parentSection.name)}/${slugify(next)}`}>
263 <span>Next →</span>
264 <p>{next}</p>
265 </Button>
266 )}
267 </div>
268 </main>
269</Layout>
270
271<style lang="scss">
272
273main {
274 margin: 2rem auto;
275 padding: 1rem;
276 width: 1000px;
277 max-width: calc(100% - 5rem);
278 position: relative;
279}
280
281section {
282 margin: 1rem 0 4rem 0;
283 padding: 1rem;
284 min-height: 8rem;
285 position: relative;
286 border: 2px solid var(--foreground);
287 box-shadow: 6px 6px 0 var(--foreground);
288 background: var(--accent-fg);
289
290}
291
292h3 {
293 font-size: 2rem;
294 margin: -2rem 0 1rem -2rem;
295 box-shadow: 6px 6px 0 var(--foreground);
296 background: var(--accent);
297 color: var(--accent-fg);
298 width: fit-content;
299 padding: 0.25rem 0.5rem;
300 }
301
302.service-head {
303 h2 {
304 font-size: 3rem;
305 margin: 0;
306 }
307 .url-wrap {
308 display: flex;
309 align-items: center;
310 gap: 0.5rem;
311 a {
312 font-size: 1.2rem;
313 }
314 .follow-with {
315 font-style: italic;
316 opacity: 0.6;
317 }
318 }
319
320}
321
322.breadcrumbs {
323 opacity: 0.5;
324 font-size: 0.8rem;
325 position: absolute;
326 right: 1rem;
327 top: 1rem;
328 a {
329 color: var(--foreground);
330 transition: all 0.15s ease-in-out;
331
332 &:hover {
333 color: var(--accent);
334 }
335 }
336}
337
338.intro {
339 font-size: 1.2rem;
340 font-style: italic;
341 opacity: 0.9;
342 display: flex;
343 gap: 0.5rem;
344 .service-icon {
345 border-radius: var(--curve-md);
346 margin-top: 1rem;
347 }
348 h4 {
349 margin-bottom: 0;
350 }
351 ul {
352 padding-left: 1rem;
353 list-style: circle;
354 font-style: normal;
355 font-size: 1rem;
356 margin-top: 0;
357 b {
358 font-size: 1rem;
359 font-weight: 400;
360 min-width: 85px;
361 display: inline-block;
362 }
363 }
364}
365
366.pagination-navigation {
367 display: flex;
368 justify-content: space-between;
369 align-items: center;
370 padding: 1rem 0;
371 :global(.button) {
372 min-width: 120px;
373 width: fit-content;
374 padding: 0.25rem 1rem;
375 text-align: right;
376 &:first-child { text-align: left; }
377 p {
378 margin: 0;
379 font-weight: normal;
380 font-size: 1rem;
381 }
382 span {
383 font-size: 0.8rem;
384 }
385
386 }
387 .nothing {
388 width: 120px;
389 }
390 .go-to-category {
391 color: var(--foreground);
392 font-size: 0.8rem;
393 opacity: 0.5;
394 @media (max-width: 768px) {
395 display: none;
396 }
397 }
398}
399
400
401
402.further-info, .notable-mentions, .word-of-warning {
403 h3 {
404 font-size: 1.4rem;
405 margin: 1rem 0;
406 }
407 :global(p) {
408 font-size: 0.9rem;
409 opacity: 0.7;
410 :global(strong) {
411 font-weight: 500;
412 }
413 :global(a) {
414 color: var(--foreground);
415 transition: all 0.15s ease-in-out;
416 &:hover {
417 color: var(--accent);
418 }
419 }
420 }
421 :global(strong) {
422 font-weight: 500;
423 }
424 :global(h4) {
425 font-size: 1.2rem;
426 margin: 0.5rem 0 0 0;
427 }
428 :global(ul) {
429 list-style: circle;
430 padding-left: 1rem;
431 font-size: 0.9rem;
432 opacity: 0.7;
433 li {
434 margin-bottom: 0.25rem;
435 :global(p) {
436 display: inline;
437 }
438 }
439 }
440}
441
442.highlights {
443 display: flex;
444 gap: 1rem;
445 flex-wrap: wrap;
446 align-items: center;
447 justify-content: end;
448
449 .meta-item, .warning {
450 display: flex;
451 align-items: center;
452 // justify-content: center;
453 gap: 0.25rem;
454 opacity: 0.6;
455 font-size: 0.9rem;
456 padding: 0.5rem 0;
457 :global(svg) {
458 color: var(--foreground);
459 width: 1.2rem;
460 height: 1.2rem;
461 }
462 a {
463 text-decoration: none;
464 color: var(--foreground);
465 display: flex;
466 gap: 0.25rem;
467 &:hover {
468 color: var(--accent-3);
469 :global(svg) {
470 color: var(--accent-3);
471 }
472 }
473 }
474 }
475 .warning {
476 color: var(--danger);
477 :global(svg) {
478 color: var(--danger);
479 }
480 }
481 .great {
482 color: #007930; // var(--success);
483 :global(svg) {
484 color: #007930; // var(--success);
485 }
486 }
487}
488
489</style>